# -*- coding: utf-8 -*-
from datetime import timedelta
from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from jms.dwd.oms.dwd_yl_oms_oms_order_incre_dt import jms_dwd__dwd_yl_oms_oms_order_incre_dt
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dm__dm_cusc_tyd_taking_waybill_detail_dt = SparkSqlOperator(
    task_id='jms_dm__dm_cusc_tyd_taking_waybill_detail_dt',
    email=['shenjiaming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_cusc_tyd_taking_waybill_detail_dt{{ execution_date | cst_ds }}',
    sql='jms/dm/dm_cusc_tyd_taking_waybill_detail_dt/execute.hql',
    executor_cores=2 , 
    driver_cores=2 , 
    executor_memory='2G' , 
    driver_memory='3G' , 
    num_executors=3 , 
    pool_slots=4,
    pool='unlimited_pool',
    conf={
        'spark.dynamicAllocation.maxExecutors'             : 4 , 
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': '320',
          'spark.shuffle.service.enabled': 'true',
          'spark.sql.shuffle.partitions': '320',
          'spark.driver.maxResultSize': '36G',
          'spark.default.paralleism': '300',  # spark.default.parallelism只有在处理RDD时有效.
          'spark.sql.broadcastTimeout': '3600',
          'spark.yarn.executor.memoryOverhead':'12G',
          'spark.core.connection.ack.wait.timeout':'600',
          'spark.shuffle.file.buffer':'64',
          'spark.reducer.maxSizeInFlight':'48',
          'spark.shuffle.io.maxRetries':'3'
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions.pernode': 5000,
              'hive.exec.max.dynamic.partitions': 30000,
              'hive.optimize.bucketmapjoin': 'true',
              'hive.optimize.bucketmapjoin.sortedmerge': 'true',
              'hive.input.format': 'org.apache.hadoop.hive.ql.io.BucketizedHiveInputFormat',
              'hive.auto.convert.sortmerge.join':'true',
              'hive.auto.convert.sortmerge.join.noconditionaltask':'true'
              },
    yarn_queue='pro',
    retries=3,
    execution_timeout=timedelta(minutes=30),
)

jms_dm__dm_cusc_tyd_taking_waybill_detail_dt << [
                                            jms_dim__dim_network_whole_massage,
                                            jms_dwd__dwd_yl_oms_oms_order_incre_dt ]
